package de.wellenblau.objectGetter
{
	
	import flash.events.ProgressEvent;
	import flash.net.URLRequest;
	
	public class objectGetter
	{
		
		protected var _myURL:URLRequest;
		private var _onComplete:Function;
		private var _scope:Object;
		private var _percent:uint;
		
		public function objectGetter(scope:Object, onComplete:Function, path:String)
		{
			_onComplete = onComplete;
			_scope = scope;
			_myURL = new URLRequest(path);
		}
		
		protected function callback(data:Array):void{
			_onComplete.apply(_scope,data);
		}
		
		protected function onProgress(e:ProgressEvent):void{
			//calc the percentage
			_percent = Math.ceil(e.bytesLoaded / e.bytesTotal * 100);
		}
	}
}